from xml.dom import minidom
import packet_set
doc=minidom.parse('gtp_normal.xml')
actions={}
i=0
for level1 in doc.childNodes :
    #print level1.toxml()
    print "level1 tagName is ", level1.tagName
    value= level1.attributes["name"].value
    print "value is ", value
    if value=="gtp_client":
        for level2 in level1.childNodes :
            if level2.toxml().strip('\r\n') <> "" :
                i+=1
                actions[i]=packet_set.gtp_custom()
                actions[i].action=level2.tagName.strip()
                print "level2 tagName is ", level2.tagName
                action=level2.tagName
                key0=level2.attributes.values()[0].name.strip()
                value0=level2.attributes.values()[0].value.strip()
                print "key0 is ", key0
                print "name is ", value0
                if key0 == "type" :
                    actions[i].type=value0
                    for level3 in level2.childNodes :
                        if level3.toxml().strip('\r\n') <> "" :
                            print "level3 is:", level3.toxml()
                            print "lelve3 tagname", level3.tagName
                            print "level3 content",level3.childNodes[0].data
                            actions[i].attr[level3.tagName]=level3.childNodes[0].data
                    print key0," is ", value0
                    
    #for name,attr in level1.attributes
    #    print "name is:", name
    #    print "attr value is: ",attr